package com.shelpe.services.sinbad.model;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class RptCustomerParam extends RptCustomerKey {
	public final static String FORMAT_DAY = "yyyy-MM-dd";

	public final static byte SOURCE_ALL = 0;
	public final static int DEVICE_MOBILE = 1;
	public final static int DEVICE_PC = 2;

	private Date startDate;
	private Date endDate;
	private int device;

	public void setupDevice(String device) {
		if (device != null) {
			if ("mobile".equals(device)) {
				this.setDevice(DEVICE_MOBILE);
			} else if ("pc".equals(device)) {
				this.setDevice(DEVICE_PC);
			} else {
				this.setDevice(SOURCE_ALL);
			}
		}
	}

	public void setupDate(String start, String end) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		if (StringUtils.isNotBlank(start)) {
			try {
				this.startDate = sdf.parse(start);
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		if (StringUtils.isNotBlank(end)) {
			try {
				this.endDate = sdf.parse(end);
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
	}
}
